import {
  createStore
} from 'vuex'
import axios from 'axios'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    objList: [],
    bag: '',
    bookObj: [],
  },
  mutations: {
    changeBackColor(state, value) {
      console.log();
      state.bag = '#' + (Math.round(Math.random() * 16777216)).toString(16)
      console.log(state.bag);
    },
    pushObj(state, value) {
      state.bookObj = value
    }
  },


  actions: {
    // getList(state) {
    //   axios.get('data(2).json').then(res => {
    //     state.commit('pushObj',res)
    //   })
    // }
	
	async getList({commit}){
		let {data} = await axios.get('data(2).json')
      commit('pushObj', data)
      console.log(data);
    }
    

  },
  plugins: [persist()]


})